package com.yaolisheng.controller;


import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yaolisheng.pojo.SysConfig;
import com.yaolisheng.result.Code;
import com.yaolisheng.result.Result;
import com.yaolisheng.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (SysConfig)表控制层
 *
 * @author yaolisheng
 * @since 2021-05-04 00:51:24
 */
@RestController
@RequestMapping("/sysConfig")
public class SysConfigController {
    /**
     * 服务对象
     */
    @Resource
    private SysConfigService sysConfigService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    public SysConfig selectOne(String id) {
        return this.sysConfigService.queryById(id);
    }


    @RequestMapping("/get")
    @HystrixCommand(fallbackMethod = "hystrixGetStatus")
    public List<SysConfig> queryAll() {
        return this.sysConfigService.queryAll(new SysConfig());
    }

    public Result hystrixGetStatus(){
        Result result = new Result();
        result.setCode(Code.ERROR);
        result.setMessage("没有数据库信息");
        return result;
    }


}